package com.cyanite.playlv2.maps;

import com.cyanite.playlv2api.types.Checkin;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;
import android.graphics.drawable.Drawable;

public class CheckinItemizedOverlay extends BaseGroupItemizedOverlay<Checkin> {

    public CheckinItemizedOverlay(Drawable defaultMarker) {
        super(defaultMarker);
    }

    @Override
    protected OverlayItem createItem(int i) {
        Checkin checkin = (Checkin)group.get(i);
        int lat = (int)(Double.parseDouble(checkin.getVenue().getGeolat()) * 1E6);
        int lng = (int)(Double.parseDouble(checkin.getVenue().getGeolong()) * 1E6);
        GeoPoint point = new GeoPoint(lat, lng);
        return new CheckinOverlayItem(point, checkin);
    }

    @Override
    public boolean onTap(GeoPoint p, MapView mapView) {
        return super.onTap(p, mapView);
    }

    public static class CheckinOverlayItem extends OverlayItem {

        private Checkin mCheckin;

        public CheckinOverlayItem(GeoPoint point, Checkin checkin) {
            super(point, checkin.getVenue().getName(), checkin.getVenue().getAddress());
            mCheckin = checkin;
        }

        public Checkin getCheckin() {
            return mCheckin;
        }
    }
}
